<%@page language="java" contentType="text/html; character=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/taglibs.jsp"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />

		<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" />
		
        <script language="javascript">
           function userDel(userId)
           {
               if(confirm('您确定删除吗？'))
               {
                   //window.location.href="<%=path %>/userDel.action?userId="+userId;
				   $.get(
						   '${ctx}/user/deleteUser/'+userId,
						   function (obj) {
							   // layer.msg(obj.message,{time:600})
							   alert(obj.message)
							   if (obj.success){
								   changeSearch(${pagers.current})
							   }
						   }
				   )
               }
           }
       </script>
	</head>

	<body leftmargin="2" topmargin="2" background='<%=path %>/img/allbg.gif'>
			<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
				<tr bgcolor="#E7E7E7">
					<td height="14" colspan="10" background="<%=path %>/img/tbg.gif">&nbsp;&nbsp;</td>
				</tr>
				<tr align="center" bgcolor="#FAFAF1" height="22">
					<td width="4%">序号</td>
					<td width="10%">账号</td>
					<td width="10%">姓名</td>
					
					<td width="5%">性别</td>
					<td width="5%">年龄</td>
					<td width="10%">住址</td>
					<td width="10%">电话</td>
					
					<td width="10%">操作</td>
		        </tr>
				<c:forEach items="${pagers.records}" var="user" varStatus="ss">
				<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td bgcolor="#FFFFFF" align="center">
						${ss.index+1}
					</td>
					<td bgcolor="#FFFFFF" align="center">
						${user.userName}
					</td>
<%--					<td bgcolor="#FFFFFF" align="center">--%>
<%--					    ${user.userPw}--%>
<%--					</td>--%>
					<td bgcolor="#FFFFFF" align="center">
						${user.userRealname}
					</td>
					<td bgcolor="#FFFFFF" align="center">
					    ${user.userSex}
					</td>
					<td bgcolor="#FFFFFF" align="center">
					    ${user.userAge}
					</td>
					<td bgcolor="#FFFFFF" align="center">
						${user.userAddress}
					</td>
					<td bgcolor="#FFFFFF" align="center">
						${user.userTel}
					</td>
					<td bgcolor="#FFFFFF" align="center">
						<a href="#" onclick="userDel(${user.userId})" class="pn-loperator">删除</a>
					</td>
				</tr>
				</c:forEach>
				<tr>
					<td colspan="8">
						<div class="pagelist">
							<pg:pager >
								<pg:last>
									共${pagers.total}记录，共${pagers.pages}页，
								</pg:last>
								当前第${pagers.current}页
								<pg:first>
									<c:choose>
										<c:when test="${pagers.current > 1}">
											<a onclick="changeSearch(1)">首页</a>
										</c:when>
									</c:choose>
								</pg:first>
								<pg:prev>
									<c:choose>
										<c:when test="${pagers.current > 1}">
											<a onclick="changeSearch(${pagers.current-1})">上一页</a>
										</c:when>
									</c:choose>
								</pg:prev>
								<pg:pages>
									<c:choose>
										<c:when test="${pagers.pages<4}">
											<c:set var="begin" value="1"/>
											<c:set var="end" value="${pagers.pages}"/>
										</c:when>
										<c:otherwise>
											<c:set var="begin" value="${pagers.current-1}"/>
											<c:set var="end" value="${pagers.current+1}"/>
											<c:if test="${begin<1}">
												<c:set var="begin" value="1"/>
												<c:set var="end" value="3"/>
											</c:if>
											<c:if test="${end>pagers.pages}">
												<c:set var="begin" value="${pagers.pages-2}"/>
												<c:set var="end" value="${pagers.pages}"/>
											</c:if>
										</c:otherwise>
									</c:choose>
									<c:forEach begin="${begin}" end="${end}" var="pageNum">
										<c:choose>
											<c:when test="${pageNum eq pagers.current}">
												<a style="background: dodgerblue" onclick="changeSearch(${pageNum})">${pageNum}</a>
											</c:when>
											<c:otherwise>
												<a onclick="changeSearch(${pageNum})">${pageNum}</a>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</pg:pages>
								<pg:next>
									<c:choose>
										<c:when test="${pagers.current < pagers.pages}">
											<a onclick="changeSearch(${pagers.current+1})">下一页</a>
										</c:when>
									</c:choose>
								</pg:next>
								<pg:last>
									<c:choose>
										<c:when test="${pagers.current eq pagers.pages}">
											<%--                                    <font color="red">尾页</font>--%>
										</c:when>
										<c:otherwise>
											<a onclick="changeSearch(${pagers.pages})">尾页</a>
										</c:otherwise>
									</c:choose>
								</pg:last>
							</pg:pager>
						</div>
					</td>
				</tr>
			</table>
			<script>
				function changeSearch(current){
					window.location.href='${ctx}/user/getUserList/'+current+'/6'
				}
			</script>
	</body>
</html>
